<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>

        <ui:composition template="../templates/employee_master.xhtml">
            <ui:define name="content">

                <f:event listener="#{complaintsController.preRenderView()}" type="preRenderView"/>
                <p:toolbar>
                    <p:toolbarGroup>
                        <p:commandButton action="#{complaintsController.prepareCreate()}" value="Create"/>

                    </p:toolbarGroup>
                </p:toolbar>
                <p:spacer height="40" />
                <p:tabView var="tab" id="tabView" dynamic="false" cache="false" value="#{complaintsController.tabs}">  
                    <p:tab id="tabComplaint" title="#{tab.title}" >
                        <p:dataTable rowIndexVar="d" value="#{tab.items}" paginator="true" rows="10"
                                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" 
                                     var="c" rowsPerPageTemplate="5,10,15" id="carTable" lazy="true">
                            
                            <p:column styleClass="complaint-status-#{c.statusName}"  headerText="ID">
                                <h:outputText value="[#{c.id}]" />
                                <br/>
                                <h:outputText value="#{c.lastUpdated}">
                                    <f:convertDateTime pattern="dd-MMM-yyyy"/>
                                </h:outputText>
                            </p:column>
                            <p:column filterBy="#{c.title}" sortBy="#{c.title}" headerText="Title">
                                <h:outputText value="#{c.title}"/>
                            </p:column>
                            <p:column sortBy="#{c.categoryName}" headerText="Category" filterBy="#{c.categoryName}">
                                <h:outputText value="#{c.categoryID.name}"/>
                            </p:column>
                            <p:column headerText="">
                                <p:commandButton action="#{complaintsController.prepareView()}" icon="ui-icon-search">
                                    <f:setPropertyActionListener target="#{complaintsController.selected}" value="#{c}"/>
                                </p:commandButton>
                            </p:column>

                        </p:dataTable>

                    </p:tab>

                </p:tabView>
            </ui:define>
            <ui:include src="../templates/complaint_status_detail.xhtml" />
        </ui:composition>
    </h:body>
</html>

